const {Model, DataTypes} = require("sequelize")
const {sequelize} = require("../config/mysql_config")
const User = require("./User");

class Advisor extends Model {
    //todo
}

Advisor.init({
        id: { type: DataTypes.INTEGER.UNSIGNED, autoIncrement: true, primaryKey: true },
        userName: {
        field: 'user_name',
        type: DataTypes.STRING(20),
        allowNull: false,
        defaultValue: '',
        unique: true,
        comment: '用户名'
    },
    dataOfBirth: {
        field: 'data_of_birth',
        type: DataTypes.DATEONLY,
        allowNull: true,
        comment: '出生日期'
    },
    gender: {
        type: DataTypes.TINYINT,
        allowNull: true,
        comment: '性别：0-女，1-男'
    },
    bio: {
        type: DataTypes.STRING(100),
        allowNull: true,
        comment: '个人简介'
    },
    aboutMe: {
        field: 'about_me',
        type: DataTypes.TEXT,
        allowNull: true,
        comment: '自我介绍'
    },
    email: {
        type: DataTypes.STRING(255),
        allowNull: true,
        comment: '邮箱',
    },
    phoneNumber: {
        field: 'phone_number',
        type: DataTypes.STRING(20),
        allowNull: true,
        comment: '电话号码'
    },
    coin: {
        type: DataTypes.INTEGER.UNSIGNED,
        allowNull: false,
        defaultValue: 0,
        comment: '当前金币余额'
    },
    password: {
        type: DataTypes.STRING(255),
        allowNull: false,
        defaultValue: '',
        comment: "用户密码"
    },
    workStatus: {
        field: 'work_status',
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: 0,
        comment: '工作状态：1 打开/0 关闭'
    },
    serviceStatus: {
        field: 'service_status',
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: 0,
        comment: '服务状态：1正在接单 / 0待接单'
    },
    totalOrderCnt: {
        field: 'total_order_cnt',
        type: DataTypes.INTEGER.UNSIGNED,
        allowNull: false,
        defaultValue: 0,
        comment: '历史订单总量(pending. completed)'
    },
    completedOrderCnt: {
      field: 'completed_order_cnt',
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      defaultValue: 0,
      comment: ' 已完成的订单总量'
    },
    score: {
        type: DataTypes.DECIMAL(3, 2),
        allowNull: false,
        defaultValue: 0.00,
        comment: '平均分 0.00-5.00'
    },
    commentCnt: {
        field: 'comment_cnt',
        type: DataTypes.INTEGER.UNSIGNED,
        allowNull: false,
        defaultValue: 0,
        comment: '评价数量'
    }
},
    {sequelize,
    modelName: 'Advisors',
    tableName: 'advisors',
    timestamps: true},
    )

module.exports = Advisor